package com.wanye.handle;

import com.wanye.entity.Result;
import com.wanye.enums.ResultEnum;
import com.wanye.utils.ResultUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by wanye on 2017/9/24.
 */
@ControllerAdvice
public class ExceptionHandle {

    Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handle(Exception e) {
        logger.error("系统异常",e);
        return ResultUtil.error(ResultEnum.UNKONWN_ERROR);
    }
}
